# encoding: utf-8

from zheezes.po.ip_addr import IpAddr 

from google.appengine.ext import webapp
from google.appengine.ext.webapp.util import run_wsgi_app

class MainPage(webapp.RequestHandler):
    def get(self):
        # bip = self.request.get("bip")
        count = self.request.get("count")
        if count:
            count = int(count)
        else:
            count = 1
        ipaddrs = IpAddr.gql("ORDER BY ip LIMIT 100");       
                        
        self.response.headers['Content-Type'] = 'text/html'
        # self.response.out.write(count)
        for ipaddr in ipaddrs:
            self.response.out.write('<p>%s - %s</p>' % (ipaddr.ip, ipaddr.addr));
        

application = webapp.WSGIApplication([('/.*', MainPage)], debug=True)

def main():
    run_wsgi_app(application)

if __name__ == "__main__":
    main()
